<table class="table table-hover">
    <thead>
        <tr>
            <!-- @if(\Encore\Admin\Facades\Admin::user()->can('shopify-sku.edit')) -->
                <th width="5%"><input type="checkbox" class="grid-select-all" /></th>
            <!-- @endif -->
            <th>平台SKU</th>
            <th>SKU</th>
            <th width="15%">名称</th>
            <th class="th-nowrap">季节性</th>
            <th>品类</th>
            <th class="th-nowrap">账号</th>
            <th class="th-nowrap">国家</th>
            <th>销售员</th>
            <th class="th-nowrap">条码类型</th>
            <th>条码</th>
            <th class="th-nowrap">启用</th>
            <!-- @if(\Encore\Admin\Facades\Admin::user()->can('shopify-sku.edit')) -->
                <th class="th-nowrap">操作</th>
            <!-- @endif -->
        </tr>
    </thead>
    <tbody>
        @foreach($paginator as $row)
            <tr>
                <!-- @if(\Encore\Admin\Facades\Admin::user()->can('shopify-sku.edit')) -->
                    <td><input type="checkbox" class="grid-row-checkbox" data-id="{{ $row->id }}" /></td>
                <!-- @endif -->
                <td>{{ $row->seller_sku ?? '' }}</td>
                <td>{{ $row->sku->psku_code ?? '' }}</td>
                <td>{{ $row->sku->psku_cn ?? '' }}</td>
                <td>{{ \App\Models\Product\ProductClassify::$_season[$row->skuClassify->season ?? 3] }}</td>
                <td>{{ $row->skuClassify->title ?? '' }}</td>
                <td>{{ $row->account->account ?? '' }}</td>
                <td>{{ $row->country->country ?? '' }}</td>
                <td>{{ \App\Util\User::getUsernameById($row->seller_id) }}</td>
                <td>{{ \App\Models\Product\ProductShopifySku::$_barcodeType[$row->barcode_type] }}</td>
                <td>{{ $row->barcode }}</td>
                <td>{!! \App\Models\Product\ProductShopifySku::displayStatus()[$row->status] !!}</td>
                <!-- @if(\Encore\Admin\Facades\Admin::user()->can('shopify-sku.edit')) -->
                    <td>
                        <a href="/xqc/products/shopify-sku/{{ $row->id }}/edit" class="grid-row-edit">
                            <i class="fa fa-edit"></i>
                        </a>
                    </td>
                <!-- @endif -->
            </tr>
        @endforeach
    </tbody>
</table>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('.grid-row-checkbox').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChanged', function () {
            var id = $(this).data('id');
            if (this.checked) {
                $.admin.grid.select(id);
                $(this).closest('tr').css('background-color', '#ffffd5');
            } else {
                $.admin.grid.unselect(id);
                $(this).closest('tr').css('background-color', '');
            }
        }).on('ifClicked', function () {
            var id = $(this).data('id');
            if (this.checked) {
                $.admin.grid.unselect(id);
            } else {
                $.admin.grid.select(id);
            }
        });

        (function () {
            $('.grid-select-all').iCheck({checkboxClass:'icheckbox_minimal-blue'});
            $('.grid-select-all').on('ifChanged', function(event) {
                if (this.checked) {
                    $('.grid-row-checkbox').iCheck('check');
                } else {
                    $('.grid-row-checkbox').iCheck('uncheck');
                }
            }).on('ifClicked', function () {
                if (this.checked) {
                    $.admin.grid.selects = {};
                } else {
                    $('.grid-row-checkbox').each(function () {
                        var id = $(this).data('id');
                        $.admin.grid.select(id);
                    });
                }
            });
        })();
    });
</script>
